﻿using System;

class Sum
{
    static void Main()
    {
        //Exercise 10.
        //Write a program to calculate the sum (with accuracy of 0.001): 1 + 1/2 - 1/3 + 1/4 - 1/5 + ...

        decimal number = 1;
        decimal sum = 1;

        for (int i = 2; i <= 100; i++)
        {
            number = 1;
            if (i % 2 == 0)
            {
                number = number / i;
            }
            else
            {
                number = -(number / i);
            }
            sum = sum + number;
        }
        Console.WriteLine("The sum is: {0:0.000}", sum);
        Console.WriteLine();
    }
}

